package com.btks.jswater.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.btks.jswater.entity.Value;
import com.btks.jswater.mapper.ValueMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CountServiceImpl {
    @Resource
    private ValueMapper valueMapper;

    public List<Value> getValue(){
        return valueMapper.getValue();

    }
    public JSONObject getplan(){
        JSONObject plan = new JSONObject();
        JSONObject plan1 = new JSONObject();
        plan1.put("name","**用水协议");
        plan1.put("part","水资源管理处");
        plan1.put("addTime","2021-10-01");
        plan1.put("updateTime","2018-01-01");
        plan.put("协议1",plan1);

        JSONObject plan2 = new JSONObject();
        plan2.put("name","**用水计划");
        plan2.put("part","水资源管理处");
        plan2.put("addTime","2021-10-01");
        plan2.put("updateTime","2018-01-01");
        plan.put("协议2",plan2);

        JSONObject plan3 = new JSONObject();
        plan3.put("name","**红线指标");
        plan3.put("part","水资源管理处");
        plan3.put("addTime","2021-11-01");
        plan3.put("updateTime","2021-01-01");
        plan.put("协议3",plan3);
        return plan;
    }
    public JSONObject getCount(){
        JSONObject js = new JSONObject();
        JSONObject js1 = new JSONObject();
        js1.put("sj",1600);
        js1.put("jh",1500);
        js1.put("cz",100);
        js.put("团结农场",js1);

        JSONObject js2 = new JSONObject();
        js2.put("sj",1600);
        js2.put("jh",1500);
        js2.put("cz",100);
        js.put("170团草场",js2);

        JSONObject js3 = new JSONObject();
        js3.put("sj",1600);
        js3.put("jh",1500);
        js3.put("cz",100);
        js.put("170团",js3);

        JSONObject js4 = new JSONObject();
        js4.put("sj",1600);
        js4.put("jh",1500);
        js4.put("cz",100);
        js.put("169团",js4);

        JSONObject js5 = new JSONObject();
        js5.put("sj",1600);
        js5.put("jh",1500);
        js5.put("cz",100);
        js.put("167团",js5);


        JSONObject js6 = new JSONObject();
        js6.put("sj",1600);
        js6.put("jh",1500);
        js6.put("cz",100);
        js.put("166团",js6);


        JSONObject js7 = new JSONObject();
        js7.put("sj",1600);
        js7.put("jh",1500);
        js7.put("cz",100);
        js.put("165团",js7);

        JSONObject js8 = new JSONObject();
        js8.put("sj",1350);
        js8.put("jh",1500);
        js8.put("cz",100);
        js.put("164团",js8);

        JSONObject js9 = new JSONObject();
        js9.put("sj",1100);
        js9.put("jh",1100);
        js9.put("cz",0);
        js.put("163团",js9);

        JSONObject js10 = new JSONObject();
        js10.put("sj",1700);
        js10.put("jh",1800);
        js10.put("cz",100);
        js.put("162团",js10);

        JSONObject js11 = new JSONObject();
        js11.put("sj",1148);
        js11.put("jh",1200);
        js11.put("cz",52);
        js.put("161团",js11);
        return js;

    }

    public PageInfo<JSONObject> getWaterInfoList(String keyword,int pnum,int nnum){
        PageInfo<JSONObject> nap = new PageInfo<>();
        if (keyword.equals("1")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getstationInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("2")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getshuiquInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("3")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getuwInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("4")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.gettuanInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("5")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getshuizhaInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("6")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getGuanquInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("7")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getpeopleInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("8")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getstationsInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("9")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getRiverInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else if(keyword.equals("10")){
            PageHelper.startPage(pnum, nnum);
            List<JSONObject> js = valueMapper.getshuikuInfo();
            PageInfo<JSONObject> res = new PageInfo<>(js);
            return res;
        }else{
            return nap;
        }
    }

    public JSONObject getWaterInfoById(String keyword,String id){
       JSONObject js1 = new JSONObject();
        if (keyword.equals("1")){
            JSONObject js = valueMapper.getstationInfoId(id);
            return js;
        }else if(keyword.equals("2")){
            JSONObject js = valueMapper.getshuiquInfoId(id);
            return js;
        }else if(keyword.equals("3")){
            JSONObject js = valueMapper.getuwId(id);
            return js;
        }else if(keyword.equals("4")){
            JSONObject js = valueMapper.gettuanId(id);
            return js;
        }else if(keyword.equals("5")){
            JSONObject js = valueMapper.getshuizhaInfoId(id);
            return js;
        }else if(keyword.equals("6")){
            JSONObject js = valueMapper.getGuanquInfoId(id);
            return js;
        }else if(keyword.equals("7")){
            JSONObject js = valueMapper.getpeopleInfoId(id);
            return js;
        }else if(keyword.equals("8")){
            JSONObject js = valueMapper.getstationsInfoId(id);
            return js;
        }else if(keyword.equals("9")){
            JSONObject js = valueMapper.getRiverId(id);
            return js;
        }else if(keyword.equals("10")){
            JSONObject js = valueMapper.getshuikuId(id);
            return js;
        }else{
            return js1;
        }
    }


}
